home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / lib231.arc / INET-ON.SLT < prev    next >
Text File  |  1990-05-11  |  7KB  |  244 lines

  1. //////////////////////////////// INET-ON.SLT //////////////////////////////////
  2. //
  3. //  INET-ON.SLT Copyright (C) 1989-90 Liberation Enterprises.
  4. //
  5. //  DESCRIPTION:  This script is included to demonstrate the use of the Custom
  6. //  Logon Script option that can be defined in each Configuration.  Also see
  7. //  INET-OFF.SLT for an example of a Custom Logoff Script.
  8. //
  9. //  CREDITS:  Password maintenance routine, and some other features modeled
  10. //  after a script originally created by Robert Wolfe.
  11. //  
  12. //  INSTRUCTIONS:  Before using this script, you must compile and run
  13. //  INETPASS.SLT.  The name of this script should then be placed in the Custom
  14. //  Logon Script option of a Liberator Configuration File, by typing INET-ON
  15. //  in the option.  The Liberator will dial the entry #(s) specified in the
  16. //  Configuration (should be the number for iNet) and open the Capture File
  17. //  defined (if any) before calling this script.  You can also use the dial
  18. //  starting time feature, available in each Command File, if you wish.  You
  19. //  must change the variables below to the proper values before re-saving and
  20. //  compiling with the command:
  21. //  CS INET-ON.  
  22. //  The name INET-OFF should also be placed in the Custom Logoff Script
  23. //  option. You must also compile INET-OFF.SLT with the command CS INET-OFF.
  24. //
  25. //  Note:  Your PCBoard password must be in the Telix dialing directory.
  26. //              ~~~~~~~
  27.                 
  28. int d = 5;       // delay before each response (in tenths/sec.)
  29.  
  30. str datapac_address[] =        "79100900",
  31.     user_id[] =                "Your.ID",     // change this to your iNet id.
  32.     inet_logon_command[] =     "A CRS GA";
  33.  
  34. //
  35. //////////////////////////////////////////////////////////////////////////////
  36. //  Nothing below should need changing.  Please remember to compile the script
  37. //  (CS INET-ON) before using it.
  38.  
  39. int f,
  40.     next_pos;
  41.  
  42. str pointer[3],
  43.     inet_password[8],
  44.     next_password[8],
  45.     password_file[64];
  46.  
  47. main()
  48. {
  49.  int t1,
  50.      t2,
  51.      t3,
  52.      t4,
  53.      t5,
  54.      t6,
  55.      t7,
  56.      t8;
  57.  
  58.  int tmark,
  59.      stat,
  60.      logon_complete = 0,
  61.      CR = '^M';
  62.  
  63. int i;
  64. str s[80];
  65.  
  66.  // Carrier detect, and PCBoard password already checked by The Liberator
  67.  // before calling this script.  If a capture file was defined in the Command
  68.  // File, it has also been opened by this point.
  69.  
  70.  if (!get_inet_password())        // Error getting iNet password.  Return
  71.   return(6);                      // abort code 6 to The Liberator.
  72.  
  73.  delay_scr(20);
  74.  cputs("...^M");                 // send 3 periods and a CR (1200 baud)
  75.  
  76.  if (waitfor("DATAPAC", 30))
  77.   {
  78.    delay_scr(d);
  79.    cputs(datapac_address);
  80.    cputc(CR);
  81.   }
  82.  else
  83.   return(10);
  84.  
  85.  t1 = track("/Code d'usager: ", 1);
  86.  t2 = track("/Code de securite: ", 1);
  87.  t3 = track("press <CR>", 1);
  88.  t4 = track("For your security",0);
  89.  t5 = track("Entered and re-entered",0);
  90.  t6 = track("Host did not accept Datapac call",1);
  91.  t7 = track("Unable to logon to host",0);
  92.  t8 = track("Logon to host computer completed", 1);
  93.  
  94.  tmark = timer_start(1800);                 // 3 minute max. for logon
  95.  
  96.  while (!time_up(tmark) && carrier())
  97.   {
  98.    terminal();
  99.    stat = track_hit(0);
  100.    
  101.    if (stat == t1)                     // send user-id
  102.     {
  103.      delay_scr(d);
  104.      cputs(user_id);
  105.      cputc(CR);
  106.     }
  107.  
  108.    else if (stat == t2)                     // send password
  109.     {
  110.      delay_scr(d);
  111.      cputs(inet_password);
  112.      cputc(CR);
  113.     }
  114.    
  115.    else if (stat == t3)                     // Access service from CR prompt
  116.     {
  117.      delay_scr(d);
  118.      cputs(inet_logon_command);
  119.      cputc(CR);
  120.     }
  121.     
  122.    else if (stat == t4)                     // password needs changing
  123.     {
  124.      waitfor("Please enter your old password", 30);
  125.      delay_scr(10);
  126.      cputs(inet_password);
  127.      cputc(CR);
  128.  
  129.      inet_password = next_password;
  130.  
  131.      waitfor("Please enter your new password", 30);
  132.      delay_scr(15);
  133.      cputs(inet_password);
  134.      cputc(CR);
  135.      waitfor("re-enter your new password", 30);
  136.      delay_scr(10);
  137.      cputs(inet_password);
  138.      cputc(CR);
  139.      f = fopen(password_file, "r+");   // open file to update pointer
  140.      itos(next_pos, pointer);
  141.      fwrite(pointer, 3, f);            // change password pointer
  142.      fclose(f);
  143.     }
  144.  
  145.    else if (stat == t5)
  146.     {
  147.      delay_scr(d);
  148.      cputs(inet_password);
  149.      cputc(CR);
  150.      waitfor("Please re-enter",10);
  151.      delay_scr(d);
  152.      cputs(inet_password);
  153.      cputc(CR);
  154.     }
  155.  
  156.    else if (stat == t6 || stat == t7)       // PCBoard not available/problems
  157.     break;                                  // say BYE/hangup below
  158.  
  159.    else if (stat == t8)                     // logon completed
  160.     {
  161.      logon_complete = 1;
  162.      clear_scr();
  163.      break;
  164.     }
  165.   }
  166.  
  167.  track_free(0);
  168.  
  169.  if (time_up(tmark) || !carrier() || !logon_complete)
  170.   {
  171.    timer_free(tmark);
  172.    if (Waitfor("iNet command",10))
  173.     {
  174.      cputs("BYE");
  175.      cputc(CR);
  176.     }
  177.    while (carrier())
  178.     {
  179.      hangup();
  180.      delay_scr(50);
  181.     }
  182.    return(29);          // Unsuccessful logon.  Send abort code.
  183.   }
  184.  
  185.  timer_free(tmark);
  186.  
  187.  return(0);            // normal termination
  188.  
  189. }
  190.  
  191. //////////////////////////////////////////////////////////////////////////////
  192. get_inet_password()
  193. {
  194.  int pos;
  195.  
  196.  password_file = _script_dir;     // Telix script directory (already checked)
  197.  strcat(password_file, "INETPASS.WRD");
  198.  
  199.  if (!filefind(password_file))
  200.   {
  201.    clear_scr();
  202.    prints("INETPASS.WRD file not found!  Disconnecting from iNet...");
  203.  
  204.    while (carrier())                 // No sense wasting iNet time while the
  205.     {                                // password file is created
  206.      hangup();
  207.      delay_scr(50);
  208.     }
  209.  
  210.    if (call("RUNME1ST") == -1)      // Attempt to create a password file
  211.     prints("Unable to create INETPASS.WRD");
  212.    delay(50);
  213.    return(0);                     // Abort the Command File
  214.   }
  215.  
  216.  f = fopen(password_file, "r");
  217.  if (!f)
  218.   return(0);
  219.  
  220.  fgets(pointer, 3, f);            // read first 3 char as pointer to password
  221.  pos = stoi(pointer);             // string to integer
  222.  fseek(f, pos, 0);                // position to start of password
  223.  fgets(inet_password, 9, f);      // get current password
  224.  next_pos = ftell(f);             // get position of next password
  225.  fgets(next_password, 9 , f);     // get next password as well
  226.  if (strlen(next_password) < 6)   // beyond last password
  227.   {
  228.    next_pos = 3;                  // reset pointer to start of passwords
  229.    fseek(f, 3, 0);                // set file pointer to start of passwords
  230.    fgets(next_password, 9, f);    // get next password
  231.   }
  232.  
  233.  fclose(f);
  234.  
  235.  if ((strlen(inet_password) < 6) || (strlen(next_password) < 6))
  236.   {
  237.    prints("Current iNet password, or next password in line is not valid.");
  238.    return(0);
  239.   }
  240.  
  241.  return(1);
  242. }
  243.  
  244. //////////////////////////////// End of file /////////////////////////////////